using CriWare;
using UnityEditor;
using UnityEngine;

namespace IQIGame.Onigao.Game.Editors
{
    [CustomEditor(typeof(GameAutoAudioSource))]
    public class GameAutoAudioSourceEditor : CriAtomSourceEditor
    {
        protected override void InspectorCueReferenceGUI()
        {
            var audioSource = (source as GameAutoAudioSource);

            EditorGUILayout.BeginVertical("box");

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("声音源类型");
            audioSource.sourceType = (AudioSourceType)EditorGUILayout.EnumPopup(audioSource.sourceType);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("逻辑适配类型");
            audioSource.adapterType = (GameAutoAudioSource.AudioSourceAdapterType)EditorGUILayout.EnumPopup(audioSource.adapterType);
            EditorGUILayout.EndHorizontal();

            switch (audioSource.adapterType)
            {
                case GameAutoAudioSource.AudioSourceAdapterType.Sound3D:
                    {
                        audioSource.playAudioDistance = EditorGUILayout.FloatField("播放声音的范围", audioSource.playAudioDistance);
                    }
                    break;
                case GameAutoAudioSource.AudioSourceAdapterType.AreaSphere:
                    {
                        audioSource.AISACDistanceName = EditorGUILayout.TextField("AISAC距离控制器名", audioSource.AISACDistanceName);
                        audioSource.sphereRadius = EditorGUILayout.FloatField("球型区域半径", audioSource.sphereRadius);
                        audioSource.playAudioDistance = EditorGUILayout.FloatField("声音衰减范围(区域外)", audioSource.playAudioDistance);
                    }
                    break;
                case GameAutoAudioSource.AudioSourceAdapterType.AreaCube:
                    {
                        audioSource.AISACDistanceName = EditorGUILayout.TextField("AISAC距离控制器名", audioSource.AISACDistanceName);
                        audioSource.cuebeHalfSize = EditorGUILayout.Vector3Field("立方体区域半径大小(xyz的一半)", audioSource.cuebeHalfSize);
                        audioSource.playAudioDistance = EditorGUILayout.FloatField("声音衰减范围(区域外)", audioSource.playAudioDistance);
                    }
                    break;

            }

            EditorGUILayout.Space(10);

            audioSource.stopAudioExtraDistance = EditorGUILayout.FloatField("停止声音的额外范围", audioSource.stopAudioExtraDistance);
            audioSource.removeSheetOnDestroy = EditorGUILayout.Toggle("销毁时移除Sheet", audioSource.removeSheetOnDestroy);

            EditorGUILayout.Space(10);

            (source as CriAtomSource).cueSheet = EditorGUILayout.TextField("Cue Sheet", (source as CriAtomSource).cueSheet);
            (source as CriAtomSource).cueName = EditorGUILayout.TextField("Cue Name", (source as CriAtomSource).cueName);

            EditorGUILayout.Space(10);

            EditorGUILayout.EndVertical();

        }
    }
}
